---
apiVersion: v1
kind: ConfigMap
metadata:
  name: prometheus-config
  namespace: monitoring
data:
  prometheus.yml: |
    global:
      scrape_interval:     15s
      external_labels:
        monitor: 'k8s-dev-monitor'
    remote_write:
      - url: http://victoriametrics-sys-connect:8428/api/v1/write
    scrape_configs:
      - job_name: 'prometheus'
        scrape_interval: 15s
        static_configs:
          - targets: ['localhost:9090']

      #========================================================================
      - job_name: 'etcd'

        kubernetes_sd_configs:
        - role: pod

        scheme: https
        tls_config:
          insecure_skip_verify: true
          ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
          cert_file: /opt/prometheus/secrets/apiserver-etcd-client.crt
          key_file: /opt/prometheus/secrets/apiserver-etcd-client.key

        relabel_configs:
          - source_labels: [__meta_kubernetes_namespace]
            action: keep
            regex: 'kube-system'
          - source_labels: [__meta_kubernetes_pod_container_name]
            action: keep
            regex: 'etcd'
          - action: labelmap
            regex: __meta_kubernetes_pod_label_(.+)
          - source_labels: [__address__]
            action: replace
            target_label: __address__
            regex: (.+?)(\\:\\d+)?
            replacement: $1:2379
